//
//  RylbVC+UI.swift
//  Auscultation
//
//  Created by 来 on 2020/12/9.
//

import Foundation

extension RylbVC {
    
    func initUI() {
        
        let top_view = UIImageView.init(image: #imageLiteral(resourceName: "beijing2@1.5x"))
        top_view.isUserInteractionEnabled = true
        view.addSubview(top_view)
        top_view.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(UIDevice.lgf_NavBarH() + 80)
        }
        self.navTitle = "人员列表"
        self.lgf_NavigationBar.style.lgf_TitleColor = UIColor.white
        self.lgf_NavigationBar.lgf_line?.isHidden = true
        self.lgf_NavigationBar.lgf_Reload()
        
        // 搜索 bar
        let search_bar = UIView.init()
        search_bar.backgroundColor = UIColor.white.withAlphaComponent(0.32)
        search_bar.layer.cornerRadius = 4
        top_view.addSubview(search_bar)
        search_bar.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(UIDevice.lgf_NavBarH() + 20)
            make.centerX.equalToSuperview()
            make.width.equalToSuperview().offset(-40)
            make.height.equalTo(40)
        }
        let search_image = UIImageView.init(image: #imageLiteral(resourceName: "sousuo@1.5x"))
        search_bar.addSubview(search_image)
        search_image.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(12)
            make.width.height.equalTo(16)
        }
        let search_text = UITextField.init()
        search_text.attributedPlaceholder = NSAttributedString.init(string:"姓名/手机号", attributes: [NSAttributedString.Key.foregroundColor:UIColor.white])
        search_text.textColor = UIColor.white
        search_text.tintColor = UIColor.white
        search_text.font = UIFont.systemFont(ofSize: 12)
        search_text.delegate = self
        search_bar.addSubview(search_text)
        search_text.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalTo(search_image.snp.right).offset(12)
            make.right.equalToSuperview()
            make.height.equalToSuperview()
        }
        
        // 人员列表
        collectionView = UICollectionView.init(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout.lgf_Layout(0, 0, 0, 0, 0, 0))
        collectionView.backgroundColor = UIColor.init(lgf_HexString: "F1F2F4")
        collectionView.lgf_Register(cellType: RylbCell.self)
        collectionView.delegate = self
        collectionView.dataSource = self
        view.addSubview(collectionView)
        collectionView.snp.makeConstraints { (make) in
            make.top.equalTo(top_view.snp.bottom)
            make.centerX.equalToSuperview()
            make.width.equalToSuperview()
            make.bottom.equalToSuperview().offset(-50)
        }
        
        let button1 = UIButton.init(type: .custom)
        button1.backgroundColor = UIColor.init(lgf_HexString: EWEDarkMode.c_0F88F2)!
        button1.setTitle("完成", for: .normal)
        button1.setTitleColor(EWEDarkMode.white(), for: .normal)
        button1.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        button1.layer.masksToBounds = true
        button1.addTarget(self, action: #selector(RylbVC.wancheng(_:)), for: .touchUpInside)
        view.addSubview(button1)
        button1.snp.makeConstraints { (make) in
            make.top.equalTo(collectionView.snp.bottom)
            make.left.right.bottom.equalToSuperview()
        }
    }
    
}
